XtGem Forum catalog

 //############################################
#include<reg52.h>
#include<stdio.h>
#include<intrins.h>
unsigned int i,j,k;
//###### ham delay tao thoi gian tre 0.5s ######
void delay(unsigned int ms)
{
unsigned int a;
unsigned char b;
for(a=0;a<ms;a++)
{
for(b=0;b<125;b++)
{
}
}
}
//##### hieu ung chop tat toan bo led ########
void hieu_ung_1(void)
{
for(k=0;k<8;k++)
{
P0=P1=P2=P3=0xff;
delay(300);
P0=P1=P2=P3=0x00;
delay(300);
}
}
//##### hieu ung chop 2 nua trai tim #########
void hieu_ung_2(void)
{
for(i=0;i<6;i++)
{
P0=P3=0x00;
delay(300);
P0=P3=0xff;
P1=P2=0x00;
delay(300);
P1=P2=0xff;
}
}
//##### hieu ung led nhay so le 1 ##############
void hieu_ung_3(void)
{
for(i=0;i<8;i++)
{
P0=P1=P2=P3=0x55;
delay(300);
P0=P1=P2=P3=0xaa;
delay(300);
}
}
//##### hieu ung led nhay so le 2 ##############
void hieu_ung_4(void)
{
for(i=0;i<8;i++)
{
P0=P1=P2=P3=0xaa;
delay(300);
P0=P1=P2=P3=0x55;
delay(300);
}
}
//##### p0,p1,p2,p3,p4 cung sang thuan ######
void hieu_ung_5(void)
{
unsigned char x,y;
x=y=255;
i=1;
j=128;
for(k=0;k<8;k++)
{
x=x-i;
y=y-j;
P0=x;
P1=P2=P3=y;
i=i*2;
j=j/2;
delay(300);
}
}
//##### p0,p1,p2,p3,p4 cung sang nghich ######
void hieu_ung_6(void)
{
unsigned char x,y;
x=y=255;
i=1;
j=128;
for(k=0;k<8;k++)
{
x=x-i;
y=y-j;
P0=y;
P1=P2=P3=x;
i=i*2;
j=j/2;
delay(300);
}
}
//##### sang dan het cac led theo chieu thuan ##
void hieu_ung_7(void)
{
unsigned char M[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,
0x80,0x00};
unsigned char N[]={0x7f,0x3f,0x1f,0x0f,0x07,0x03,
0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0;i<8;i++)
{
P0=M[i];
delay(300);
}
for(i=0;i<8;i++)
{
P2=N[i];
delay(300);
}for(i=0;i<8;i++)
{
P3=N[i];
delay(300);
}for(i=0;i<8;i++)
{
P1=N[i];
delay(300);
}
}
//##### tat dan het cac led theo chieu thuan ############
void hieu_ung_8(void)
{
unsigned char M[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]={0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0x00;
for(i=0;i<8;i++)
{
P0=M[i];
delay(300);
}
for(i=0;i<8;i++)
{
P2=N[i];
delay(300);
}for(i=0;i<8;i++)
{
P3=N[i];
delay(300);
}for(i=0;i<8;i++)
{
P1=N[i];
delay(300);
}
}
//##### sang dan het cac led theo chieu nghich #####
void hieu_ung_9(void)
{
unsigned char M[]={0xfe,0xfc,0xf8,0xf0,0xe0,0xc0,0x80,0x00};
unsigned char N[]={0x7f,0x3f,0x1f,0x0f,0x07,0x03,0x01,0x00};
P0=P1=P2=P3=0xff;
for(i=0;i<8;i++)
{
P1=M[i];
delay(300);
}
for(i=0;i<8;i++)
{
P3=M[i];
delay(300);
}for(i=0;i<8;i++)
{
P2=M[i];
delay(300);
}for(i=0;i<8;i++)
{
P0=N[i];
delay(300);
}
}
//##### tat dan het cac led theo chieu nghich #####
void hieu_ung_10(void)
{
unsigned char M[]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
unsigned char N[]={0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
P0=P1=P2=P3=0x00;
for(i=0;i<8;i++)
{
P1=M[i];
delay(300);
}
for(i=0;i<8;i++)
{
P3=M[i];
delay(300);
}for(i=0;i<8;i++)
{
P2=M[i];
delay(300);
}for(i=0;i<8;i++)
{
P0=N[i];
delay(300);
}
}
//##### hieu ung pro 1 #################
void hieu_ung_11(void)
{
unsigned char M[]={0xf0,0xe1,0xc3,0x87,0x0f};
unsigned char N[]={0x0f,0x4f,0x63,0x71,0x78};
unsigned char L[]={0x1f,0x4f,0x6f,0x73,0x79,0x7c};
unsigned char K[]={0x3f,0x5f,0x6f,0x77,0x7b,0x7d,0x7e};
P0=P1=P2=P3=0xff;
for(i=0;i<5;i++)
{
P0=M[i];
delay(300);
}
P0=0xff;
for(i=0;i<5;i++)
{
P2=N[i];
delay(300);
}
P2=0x7f;
for(i=0;i<6;i++)
{
P3=L[i];
delay(300);
}
P2=P3=0x7f;
for(i=0;i<7;i++)
{
P1=K[i];
delay(300);
}
P1=P2=P3=0x7f;
}